package com.example.stgv;

import java.util.ArrayList;

import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;

public class DanhSachHocSinh extends Activity {

	private DBHelper db;
	ListView lvDanhSach;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_danh_sach_hoc_sinh);

		LopHocsData lopx = new LopHocsData();

/*		Cursor cur1 = db.getAllData(lopx.getDATABASE_TABLE_LOP());
		ArrayList<String> arrlop = new ArrayList<String>();
		Tab[] mTab = new Tab[cur1.getCount()];
		int i = 0;
		if (cur1.moveToFirst()) {
			do {
				mTab[i] = getActionBar().newTab()
						.setText(cur1.getString(1).toUpperCase())
						.setTabListener(new NavTabListener());
				ActionBar.addTab( mTab[i]); 
			} while (cur1.moveToNext());
		}

		ActionBar actionBar = getActionBar();
		actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);*/

		HocSinhData hocsinhx = new HocSinhData();
		db = new DBHelper(this);
		Cursor cur = db.getAllData(hocsinhx.getDATABASE_TABLE_HOCSINH());
		ArrayList<HocSinhData> arrhocsinhObj = new ArrayList<HocSinhData>();
		if (cur.moveToFirst()) {
			do {
				arrhocsinhObj.add(new HocSinhData(cur.getString(0), cur
						.getString(1), cur.getString(2), cur.getString(3), cur
						.getString(4)));
			} while (cur.moveToNext());
		}
		cur.close();
		db.close();
		lvDanhSach = (ListView) this.findViewById(R.id.lsthocsinh_DanhSach);
		HocSinhAdaptor adapter = new HocSinhAdaptor(this, arrhocsinhObj);
		lvDanhSach.setAdapter(adapter);

	}


	private class NavTabListener implements ActionBar.TabListener {
		public NavTabListener() {
		}

		@Override
		public void onTabReselected(Tab tab, FragmentTransaction ft) {
		}

		@Override
		public void onTabSelected(Tab tab, FragmentTransaction ft) {
			/*
			 * if (tab.equals(mTab1)) { showList(); } else if
			 * (tab.equals(mTab2)) { showCustomList(); }
			 */
		}

		@Override
		public void onTabUnselected(Tab arg0, FragmentTransaction arg1) {
			// TODO Auto-generated method stub

		}
	}
}
